<template>
  <el-switch v-model="row.is_receive" :disabled="disabled" :active-value="1" :inactive-value="0" @change="changeStatus" />
</template>

<script>
export default {
  name: 'IsReceive',
  props: {
    row: {
      type: Object,
      default: _ => {
        return {};
      }
    }
  },
  data() {
    return {
      disabled: false
    };
  },
  methods: {
    changeStatus: function(value) {
      this.disabled = true;
      this.$http.put(
          '/admin/market/ticket/' + this.row.ticket_id + '/coupon/' + this.row.id + '/edit/is_receive',
          { is_receive: value },
          _ => {
            this.disabled = false;
          },
          error => {
            this.$message.error(error.msg);
          },
          false
      );
    }
  }
};
</script>

<style></style>
